﻿namespace Macds.Core.Task
{
    using System.Timers;

    public class TaskProcess
    {
        public TaskProcess(ITask task)
        {
            this.Task = task;
            this.TimerInternal = new Timer(task.Interval);
            var del = new ElapsedEventHandler((obj, arg) => { this.TimerInternal.Stop(); task.Process(); this.TimerInternal.Interval = task.Interval;  this.TimerInternal.Start(); });
            this.TimerInternal.Elapsed += del;
        }

        public Timer TimerInternal { get; set; }
        public ITask Task { get; set; }
    }
}
